package com.bjtu.transactionclient.base.exceptions;

/**
 * @author caiyuli
 * @date 2020-02-18 20:44
 */

//使用：  throw new BaseException
public class BaseException extends RuntimeException {

    private Integer code;
    private String message;

    public BaseException(ExceptionEnum exceptionEnum) {
        this.message = exceptionEnum.getMessage();
        this.code = exceptionEnum.getCode();
    }

    public BaseException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return null == message ? super.getMessage() : message;
    }
}
